package com.xish.api;

import static java.lang.Math.*;

public class GeoLocation {

    private Double latitude;
    private Double longitude;

    public GeoLocation() {
    }

    public GeoLocation(Double latitude, Double longitude) {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double distance(GeoLocation location) {
        return (6371 * acos(cos(toRadians(location.getLatitude())) * cos(toRadians(getLatitude())) * cos(toRadians(getLongitude()) - toRadians(location.getLongitude())) + sin(toRadians(location.getLatitude())) * sin(toRadians(getLatitude()))));
    }
}
